package com.three.service.impl;

import com.baor.baseUtil.R;
import com.three.dao.TeacherDao;
import com.three.domain.Users;
import com.three.service.TeacherService;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional(rollbackFor = Exception.class)
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao teacherDao;

    @Override
    public R updateTeacher(Users users) {
        String plainPassword = users.getPassword();
        String hashedPassword = BCrypt.hashpw(plainPassword, BCrypt.gensalt());
        users.setPassword(hashedPassword);
        return R.ok(teacherDao.updateTeacher(users));
    }


}
